import { createApp } from 'vue'
import App from './App.vue'

import { router } from '@/router'      // 路由
import './router/permission' // 👈 必须导入守卫文件
import store from './store/index.js'             // Vuex
import axios from './axios/index'                // Axios 封装
import VueAxios from 'vue-axios'

// 引入公共样式
import './css/core.css' // 引入核心样式

//引入fontawesome字体
import '@/assets/fontawesome/css/all.min.css'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn';
// 修改分页器默认文字
zhCn.el.pagination.total = '共{total}条';
zhCn.el.pagination.goto = '跳至';
zhCn.el.pagination.pagesize = '条/页';
zhCn.el.pagination.pageClassifier = '页';


import Avue from '@smallwei/avue'                // Avue 兼容 Vue 3 的版本（>=3.x）
import '@smallwei/avue/lib/index.css'

import * as util from './util/util'
import * as config from './util/config'
import { HttpService } from './util/httpService'
// 如果您正在使用CDN引入，请删除下面一行。
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 创建 App 实例
const app = createApp(App)


for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}

// 全局属性挂载
app.provide('axios', axios)
app.provide('util', util)
app.provide('config', config)
app.provide('httpService', new HttpService())

// 插件注册
app.use(router)
app.use(store)
app.use(VueAxios, axios)
app.use(ElementPlus,{locale:zhCn})
app.use(Avue)

// 挂载到 DOM
app.mount('#app')

// 可选：挂载到全局 window
window.axios = axios
